<template>
  <div class="d_main">
    <!-- 操作区 S-->
    <div class="d_operationBox">
      <div class="d_btn">
        <el-button
          type="primary"
          size="small"
          icon="el-icon-plus"
          @click="newAddClick"
           v-permission="'MenuCode5-2-3-1'"
          >新建</el-button
        >
      </div>
      <div class="d_search">
      <screec
          v-model="search.QueryDataBaseFiled"
          :headData.sync="tableHead"
          :disabled="searchLoading"
        ></screec>
        <el-input
          v-model="search.likeWords"
          placeholder="请输入关键字"
          size="small"
          @keyup.enter.native="getDataLists"
        >
          <el-button
            slot="append"
            :loading="searchLoading"
            type="primary"
            icon="el-icon-search"
            :disabled="searchLoading"
            element-loading-spinner="el-icon-loading"
            @click="getDataLists"
          >
            搜索
          </el-button>
        </el-input>
      </div>
    </div>
    <!-- 操作区 E-->
    <!-- 表格操作区 S-->
    <div class="d_tableOperation">
      <div class="d_condition"></div>
      <div class="d_set">
        <div @click="Refresh"><i class="d_icon el-icon-refresh-right" /></div>
        <div class="setting flex">
          <HeadSeting
            :list-data.sync="tableHead"
            :table-code="$config.inStockProductList"
            @reset="getTableHead"
          />
        </div>
      </div>
    </div>
    <!-- 表格操作区 E-->
    <div ref="tableCon" class="tableCon">
      <el-table
        v-show="tableHead.length > 0"
        id="emtable"
        ref="multipleTable"
        v-loading="searchLoading"
        :data="dataList"
        :height="tableHeight || 'auto'"
        border
        fit
        style="width: 100%"
        @header-dragend="surverWidth"
      >
        <template v-for="(fruit, index) in tableHead">
          <el-table-column
            v-if="fruit.visible"
            :key="index"
            :label="fruit.columnName"
            :min-width="fruit.columnWidth || 110"
            :prop="fruit.columnCode"
            show-overflow-tooltip
            :fixed="fruit.isFloat ? 'left' : false"
          >
            <template slot-scope="scope">
              <template v-if="fruit.columnCode === 'inStockProductStateName'">
                <div class="flex">
                  <template v-if="scope.row.inStockProductState === 0">
                    <span class="mr5 spot" style="background: #3f61f1" /><span
                      >待确认</span
                    >
                  </template>
                  <template v-else-if="scope.row.inStockProductState === 1">
                    <span class="mr5 spot" style="background: #67c23a" /><span
                      >已确认</span
                    >
                  </template>
                  <template v-else>
                    <span class="mr5 spot" style="background: #e13335" /><span
                      >已拒绝</span
                    >
                  </template>
                </div>
              </template>
              <template v-else>
                {{ scope.row[fruit.columnCode] }}
              </template>
            </template>
          </el-table-column>
        </template>
        <el-table-column label="操作" width="70px" fixed="right" align="center">
          <template slot-scope="scope">
            <div>
              <el-popover
                :ref="`popover-${scope.$index}`"
                placement="bottom-end"
                popper-class="tableOp"
                width="160"
                :popper-options="{
                  boundariesElement: 'opBox',
                  removeOnDestroy: true,
                }"
                trigger="click"
              >
                <div class="operation">
                  <ul>
                    <li @click="seeInfo(scope.row)">查看</li>
                  </ul>
                </div>
                <div slot="reference" class="opBox pointer">
                  <span class="el-icon-more c_3F61F1" />
                </div>
              </el-popover>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 骨架屏     -->
      <div v-if="tableHead.length == 0" class="p16">
        <el-skeleton :rows="6" animated />
      </div>
    </div>
    <!-- 分页 S-->
    <div class="d_pag">
      <pagination
        :total="total || 0"
        :page.sync="search.pageIndex"
        :limit.sync="search.pageSize"
        @pagination="getDataLists"
      />
    </div>
    <!-- 分页 E-->
    <!-- 选择缴库单 -->
    <el-dialog
      v-dialogDrag
      title="选择缴库单"
      :visible.sync="isTreasuryVisible"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog"
      width="85%"
    >
      <div class="dialogDody">
        <!-- 搜索     -->
        <div class="btnCon flex flex_between" style="border-bottom: none">
          <!--      搜索框-->
          <div class="search">
            <el-input
              v-model="treasurySearch.likeWords"
              prefix-icon="el-icon-search"
              @keyup.enter.native="getTreasuryList"
              placeholder="输入关键字"
              size="small"
            >
            </el-input>
          </div>
        </div>
        <!-- 表格区域       -->
        <div class="tableCon lastTdNoBorder pt0" style="padding:16px">
          <el-table
            v-loading="treasuryLoading"
            :data="treasuryList"
            height="560"
            :row-class-name="tableRowClassName"
            border
            style="width: 100%"
          >
            <el-table-column
              prop="handInBillNo"
              label="缴库单号"
              min-width="160"
            />
            <el-table-column
              prop="handInTypeName"
              label="缴库类型"
              min-width="100"
            />
            <el-table-column
              prop="createDate"
              label="缴库时间"
              show-overflow-tooltip
              min-width="110"
            />
            <el-table-column
              prop="xieYiShuHao"
              label="订单单号"
              min-width="150"
            />
            <el-table-column
              prop="customerBillNo"
              label="客户单号"
              show-overflow-tooltip
              min-width="110"
            />
            <!-- <el-table-column
              prop="productNo"
              label="产品编码"
              show-overflow-tooltip
              min-width="110"
            /> -->
            <el-table-column
              prop="productName"
              label="产品名称"
              min-width="190"
              show-overflow-tooltip
            />
            <el-table-column
              prop="customerName"
              label="所属客户"
              show-overflow-tooltip
              min-width="120"
            />
            <el-table-column
              prop="detailCount"
              label="明细"
              show-overflow-tooltip
              min-width="120"
            />
            <el-table-column prop="handInSumBoxs" label="箱数" min-width="90" />
            <el-table-column
              prop="handInSumQuantity"
              label="数量"
              show-overflow-tooltip
              min-width="120"
            />
            <el-table-column
              prop="handInDepartmentName"
              label="缴库部门"
              min-width="90"
            />
            <el-table-column
              prop="handInPersonName"
              label="缴库人员"
              min-width="90"
            />
            <el-table-column
              prop="handInRemark"
              label="备注"
              min-width="150"
              show-overflow-tooltip
            >
              <template scope="{row}">
                {{ row.handInRemark || "--" }}
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              width="100px"
              fixed="right"
              align="center"
            >
              <template slot-scope="scope">
                <el-button
                  type="text"
                  size="medium"
                  style="color: #606266"
                  @click="confirmSelecd(scope.row)"
                >
                  选择
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isTreasuryVisible = false"
          >取 消</el-button
        >
        <el-button type="primary" size="mini" @click="confirmSelecd"
          >确定</el-button
        >
      </span> -->
    </el-dialog>
    <!--  新建/编辑成品入库   -->
    <el-dialog
      :title="ops === 'modify' ? '编辑成品入库' : '新建成品入库'"
      :visible.sync="isAddDialog"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog"
      width="85%"
      @close="closeDialog"
    >
      <div class="dialogDody">
        <div class="subTip">
          <span class="mr15"
            ><span class="mr5">入库单号：</span
            >{{ instockForm.inStockProductNo || "系统自动生成" }}</span
          >
          <span class="mr15"
            ><span class="mr5">创建日期：</span
            >{{ instockForm.createTime || dayjs().format("YYYY-MM-DD") }}</span
          >
          <span class="mr15"
            ><span class="mr5">创建人员：</span
            >{{ ops === "modify" ? instockForm.createor : name }}</span
          >

          <!-- <span class="mr15"
            ><span class="mr5">产品编码：</span
            >{{ instockForm.productNo }}</span
          > -->
        </div>
        <div class="addWuliaoBox">
          <el-form
            ref="instockForm"
            :model="instockForm"
            :rules="rules"
            label-width="95px"
            label-position="left"
            class="dialogForm dialogInlineForm"
          >
            <el-row>
              <el-col :span="8">
                <el-form-item label="入库类型">
                  <el-input
                    v-model="instockForm.inStockTypeName"
                    placeholder="请输入领料类型"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="关联单据">
                  <el-input
                    v-model="instockForm.handInBillNo"
                    placeholder="关联单据"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="申请人员">
                  <el-input
                    v-model="instockForm.inStockApplyPersonName"
                    placeholder="请输入内容"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="所属客户">
                  <el-input
                    v-model="instockForm.customerName"
                    placeholder="所属客户"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="产品名称">
                  <el-input
                    v-model="instockForm.productName"
                    placeholder="产品名称"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="产品单位">
                  <el-input
                    v-model="instockForm.productUnit"
                    placeholder="产品单位"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="客户单号">
                  <el-input
                    v-model="instockForm.customerCode"
                    placeholder="客户单号"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="缴库备注" class="inlineText">
                  <el-input
                    v-model="instockForm.handInRemark"
                    type="textarea"
                    :rows="1"
                    placeholder="请输入缴库备注"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item
                  label="入库备注"
                  class="inlineText mt5"
                  prop="inStockBillRemark"
                >
                  <el-input
                    v-model="instockForm.inStockBillRemark"
                    type="textarea"
                    :rows="1"
                    placeholder="请输入入库备注"
                    size="mini"
                    clearable
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div class="tableBox lastTdNoBorder">
            <div class="tt flex flex_between">
              <span class="fw">缴库明细</span>
            </div>
            <el-table
              v-loading="infoLoading"
              :data="instockForm.inStockBillMxList"
              border
              style="width: 100%"
            >
              <el-table-column
                label="纸箱规格"
                prop="cartonSizeName"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="包装描述"
                prop="packageDescription"
                min-width="90"
              />
              <el-table-column
                label="每箱数量"
                prop="eachBoxQuantity"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="缴库箱数"
                prop="handInBoxs"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="实际数量"
                prop="handInQuantity"
                min-width="90"
              />
              <el-table-column
                label="公斤数"
                show-overflow-tooltip
                min-width="90"
                prop="kilogramQuantity"
              >
                <template slot-scope="{ row }">
                  <el-input
                    v-model="row.kilogramQuantity"
                    placeholder="公斤数"
                    size="mini"
                  />
                </template>
              </el-table-column>
              <el-table-column label="库位" prop="stockArea" min-width="150">
                <template slot-scope="{ row }">
                  <el-cascader
                    v-model="row.stockArea"
                    size="mini"
                    clearable
                    :options="storageLocations"
                    :props="{ label: 'name', value: 'code' }"
                  />
                </template>
              </el-table-column>
              <el-table-column
                label="备注"
                show-overflow-tooltip
                min-width="150"
                prop="handInMxRemark"
              >
                <template slot-scope="{ row }">
                  <el-input
                    v-model="row.handInMxRemark"
                    placeholder="备注"
                    size="mini"
                  />
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isAddDialog = false">取 消</el-button>
        <!-- 拒绝       -->
        <el-button
          :loading="addLoading"
          :disabled="addLoading"
          element-loading-spinner="el-icon-loading"
          type="warning"
          size="mini"
          @click="refuseOut"
          >拒绝</el-button
        >
        <!--  同意      -->
        <el-button
          :loading="addLoading"
          :disabled="addLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="saveAdd"
          >同意</el-button
        >
      </div>
    </el-dialog>
    <!--  查看成品入库   -->
    <el-dialog
      title="查看成品入库"
      :visible.sync="isSeevisible"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog"
      width="85%"
      @close="closeDialog"
    >
      <div class="dialogDody">
        <div class="subTip">
          <span class="mr15"
            ><span class="mr5">入库单号：</span
            >{{ instockForm.inStockBillNo }}</span
          >
          <span class="mr15"
            ><span class="mr5">创建日期：</span
            >{{ instockForm.createTime || dayjs().format("YYYY-MM-DD") }}</span
          >
          <span
            ><span class="mr5">创建人员：</span
            >{{instockForm.createPersonName }}</span
          >

          <!-- <span class="mr15"
            ><span class="mr5">产品编码：</span
            >{{ instockForm.productNo }}</span
          > -->
        </div>
        <div class="addWuliaoBox">
          <el-form
            ref="instockForm"
            :model="instockForm"
            :rules="rules"
            label-width="95px"
            label-position="left"
            class="dialogForm dialogInlineForm"
          >
            <el-row>
              <el-col :span="8">
                <el-form-item label="入库类型">
                  <el-input
                    v-model="instockForm.inStockTypeName"
                    placeholder="请输入领料类型"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="关联单据">
                  <el-input
                    v-model="instockForm.associationBillNo"
                    placeholder="关联单据"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="申请人员">
                  <el-input
                    v-model="instockForm.inStockApplyPersonName"
                    placeholder="请输入内容"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="所属客户">
                  <el-input
                    v-model="instockForm.customerName"
                    placeholder="所属客户"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="产品名称">
                  <el-input
                    v-model="instockForm.productName"
                    placeholder="产品名称"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="产品单位">
                  <el-input
                    v-model="instockForm.productUnit"
                    placeholder="产品单位"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="客户单号">
                  <el-input
                    v-model="instockForm.customerBillNo"
                    placeholder="客户单号"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="版本版面">
                  <el-input
                    v-model="instockForm.productVersion"
                    placeholder="版本版面"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="生产单号">
                  <el-input
                    v-model="instockForm.getMaterialBillNo"
                    placeholder="生产单号"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="缴库备注" class="inlineText">
                  <el-input
                    v-model="instockForm.handInRemark"
                    type="textarea"
                    :rows="1"
                    placeholder="请输入缴库备注"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item
                  label="入库备注"
                  class="inlineText mt5"
                  prop="inStockBillRemark"
                >
                  <el-input
                    v-model="instockForm.inStockBillRemark"
                    type="textarea"
                    :rows="1"
                    placeholder="请输入入库备注"
                    size="mini"
                    disabled
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <div class="tableBox lastTdNoBorder">
            <div class="tt flex flex_between">
              <span class="fw">缴库明细</span>
            </div>
            <el-table
              v-loading="infoLoading"
              :data="instockForm.detailList"
              border
              style="width: 100%"
            >
              <el-table-column
                label="纸箱规格"
                prop="cartonSizeName"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="包装描述"
                prop="packageDescription"
                min-width="90"
              />
              <el-table-column
                label="每箱数量"
                prop="eachBoxQuantity"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="缴库箱数"
                prop="handInBoxs"
                show-overflow-tooltip
                min-width="110"
              />
              <el-table-column
                label="实际数量"
                prop="handInQuantity"
                min-width="90"
              />
              <el-table-column
                label="公斤数"
                show-overflow-tooltip
                min-width="90"
                prop="kilogramQuantity"
              />
              <el-table-column
                label="备注"
                show-overflow-tooltip
                min-width="150"
                prop="handInMxRemark"
              />
            </el-table>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isSeevisible = false">取 消</el-button>
        <!--  确定     -->
        <el-button type="primary" size="mini" @click="isSeevisible = false"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!--    拒绝原因弹框-->
    <el-dialog
      title="拒绝原因"
      :visible.sync="reasonVisible"
      :close-on-click-modal="false"
      custom-class="comDialog"
      append-to-body
      width="30%"
      @close="closeCancelDialog"
    >
      <div class="dialogDody">
        <el-form
          ref="cancelForm"
          :model="cancelForm"
          :rules="cancelRules"
          label-width="0px"
          class="dialogForm"
        >
          <el-form-item label="" prop="stockStateDesc">
            <el-input
              v-model="cancelForm.stockStateDesc"
              type="textarea"
              :autosize="{ minRows: 2 }"
              placeholder="请输入内容"
              size="mini"
              clearable
            />
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="reasonVisible = false">取 消</el-button>
        <el-button
          v-loading="addLableLoading"
          :disabled="addLableLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="refuseInstock"
          >保存</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
import MixA from "@/utils/mixin";
import { arraySort } from "@/utils";
import Pagination from "@/components/Pagination";
import HeadSeting from "@/components/HeadSeting";
import screec from "@/components/screen";
const mixa = new MixA();
import { mapGetters } from "vuex";
export default {
  name: "",
  components: { Pagination, HeadSeting,screec },
  mixins: [mixa],
  computed: {
    ...mapGetters(["name", "userInfo"]),
  },
  data() {
    return {
      ops: "add",
      isSeevisible: false, // 查看弹框是否显示
      addLableLoading: false, // 拒绝按钮加载效果
      reasonVisible: false, // 拒绝领料出库弹框是否显示
      infoLoading: false, // 明细列表加载
      isAddDialog: false, // 新建弹框显示隐藏
      addLoading: false, // 按钮加载效果
      treasuryLoading: false, // 缴库单列表加载
      isTreasuryVisible: false, // 缴库单选择弹框显示隐藏
      searchLoading: false, // 缴库入库列表加载效果
      search: {
        QueryDataBaseFiled:'',
        pageIndex: 1,
        pageSize: 30,
        likeWords: "",
        inStockType: 1,
      },
      total: 0,
      dataList: [],
      tableHead: [], // 表头
      tableHeight: null,
      radioSelect: null,
      treasuryList: [], // 缴库单列表
      treasurySearch: {
        saleOrderNo: "",
        likeWords: "",
        handInType: 1,
      },
      currentRow: {}, // 交库单列表单选选中值
      instockForm: {
        inStockType: "InStockProductType1",
        inStockTypeName: "成品入库", // 入库类型名称
        handInBillNo: "", // 关联单据号
        inStockProductPerson: "", // 申请人员code
        inStockApplyPersonName: "", // 申请人员name
        handInRemark: "", // 缴库备注
        inStockBillRemark: "", // 入库单备注
        customerCode: "", // 所属客户编码
        customerName: "", // 所属客户name
        productName: "", // 产品名称
        productUnit: "", //单位
        inStockBillMxList: [],
      },
      storageLocations: [], // 库区库位
      cancelForm: {
        stockStateDesc: "",
      },
      rules: {},
      cancelRules: {
        stockStateDesc: [
          { required: true, message: "请填写拒绝原因", trigger: "change" },
        ],
      },
    };
  },
  created() {
    // 缴库入库表头
    this.getTableHead();
    // 库区库位
    this.getStorageLocations();
  },
  mounted() {
    this.calHeight();
  },
  methods: {
    // 拒绝保存事件
    refuseInstock() {
      this.$refs.cancelForm.validate((valid) => {
        if (valid) {
          this.addLableLoading = true;
          const params = {
            handInBillNo: this.instockForm.handInBillNo,
            inStockRefuseReason: this.cancelForm.stockStateDesc,
          };
          this.$api.warehouse
            .RefuseProductHandInBill(params)
            .then(() => {
              this.$message({
                message: "已拒绝",
                type: "success",
              });
              this.getDataLists();
              this.isAddDialog = false;
              this.reasonVisible = false;
            })
            .catch(() => {
              this.addLableLoading = false;
            });
        }
      });
    },
    // 拒绝入库点击事件
    refuseOut() {
      this.reasonVisible = true;
    },
    // 同意入库
    saveAdd() {
      let isVer = true;
      for (let i = 0; i < this.instockForm.inStockBillMxList.length; i++) {
        if (this.instockForm.inStockBillMxList[i].stockArea.length < 1) {
          isVer = false;
          break;
        } else {
          this.instockForm.inStockBillMxList[i].warehouseAreaCode =
            this.instockForm.inStockBillMxList[i].stockArea[0];
          this.instockForm.inStockBillMxList[i].areaShelfCode =
            this.instockForm.inStockBillMxList[i].stockArea[1];
        }
      }
      if (isVer) {
        const params = this.instockForm;
        this.addLoading = true;
        this.$api.warehouse
          .AddInStockProduct(params)
          .then(() => {
            this.$message({
              message: "入库成功",
              type: "success",
            });
            this.getDataLists();
            this.isAddDialog = false;
            this.addLoading = false;
          })
          .catch(() => {
            this.addLoading = false;
          });
      } else {
        this.$message({
          message: "请选择相应入库库位",
          type: "warning",
        });
      }
    },
    // 新建缴库点击事件
    newAddClick() {
      this.isTreasuryVisible = true;
      // 获取缴库单列表
      this.getTreasuryList();
    },
    // 查看点击事件
    seeInfo(data) {
      this.isSeevisible = true;
      this.ops = "see";
      this.getInfo(data.inStockID);
    },
    // 领料单详情
    getInfo(id) {
      const params = {
        queryBy: 1,
        queryValue: id,
      };
      this.infoLoading = true;
      this.$api.warehouse
        .GetSingleInStockProduct(params)
        .then((res) => {
          const arr = [...res.detailList];
          arr.forEach((item) => {
            const newArr = [];
            newArr.push(item.warehouseAreaCode, item.areaShelfCode);
            item.stockArea = newArr;
          });
          this.instockForm = res;
          this.infoLoading = false;
        })
        .catch(() => {
          this.infoLoading = false;
        });
    },
    // 缴库单选择确认事件
    confirmSelecd(row) {
      const arr = JSON.parse(JSON.stringify(row.mxDataList));
      arr.forEach((item) => {
        item.stockArea = [];
      });
      this.instockForm.inStockBillMxList = arr;
      this.instockForm.inStockTypeName = row.handInTypeName;
      this.instockForm.handInBillNo = row.handInBillNo;
      this.instockForm.handInBillNo = row.handInBillNo;
      this.instockForm.inStockProductPerson = row.handInPersonNo;
      this.instockForm.customerCode = row.customerBillNo;
      this.instockForm.customerName = row.customerName;
      this.instockForm.productName = row.productName;
      this.instockForm.handInRemark = row.handInRemark;
      this.instockForm.productNo = row.productNo;
      this.instockForm.productUnit = row.productUnit;
      this.instockForm.inStockApplyPersonName =
        row.handInPersonName;
      this.isTreasuryVisible = false;
      this.isAddDialog = true;
    },
    // 库区库位
    getStorageLocations() {
      const parmas = {
        warehouseCode: "",
      };
      this.$api.warehouse.GetStockQueryAreaTreeView(parmas).then((res) => {
        this.storageLocations = res;
      });
    },
    // 给选中一行添加class
    tableRowClassName({ row }) {
      if (this.currentRow.handInBillNo === row.handInBillNo) {
        return "selectd";
      }
    },
    // 获取缴库单列表
    getTreasuryList() {
      this.treasuryLoading = true;
      this.$api.warehouse
        .GetMatchProductHandInBills(this.treasurySearch)
        .then((res) => {
          this.treasuryList = res;
          this.treasuryLoading = false;
        })
        .catch(() => {
          this.treasuryLoading = false;
        });
    },
    // 缴库入库列表，清除所有查询条件
    Refresh() {
      this.search = this.$options.data().search;
      this.getDataLists();
    },
    // 缴库入库表头
    getTableHead() {
      const parmas = {
        tableCode: this.$config.inStockProductList,
      };
      this.$api.common.getAllTableHead(parmas).then((res) => {
        res.sort(arraySort("columnSort"));
        this.tableHead = res;
        // 领料出库列表
        this.getDataLists();
      });
    },
    // 缴库入库列表
    getDataLists() {
      const params = this.search;
      this.searchLoading = true;
      this.$api.warehouse
        .GetMatchPageInStockProducts(params)
        .then((res) => {
          this.dataList = res.list;
          this.dataList.forEach((item)=>{
            for(let i in item){
              if(!item[i] && item[i] !== 0){
                item[i] = '--'
              }
            }
          })
          this.total = res.totalCount;
          this.searchLoading = false;
        })
        .catch(() => {
          this.searchLoading = false;
        });
    },
    calHeight() {
      this.$nextTick(() => {
        const rect = this.$refs.tableCon.getBoundingClientRect();
        this.tableHeight = rect.height;
      });
    },
    closeDialog() {
      if (this.$refs.instockForm) {
        this.$refs.instockForm.resetFields();
      }
      this.instockForm = this.$options.data().instockForm;
    },
    closeCancelDialog() {
      if (this.$refs.cancelForm) {
        this.$refs.cancelForm.resetFields();
      }
      this.cancelForm = this.$options.data().cancelForm;
    },
  },
};
</script>
<style lang="scss" scoped>
.spot {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 100%;
}
.subTip {
  border-bottom: 1px #e6e6e6 solid;
  background: #f5f6f9;
  padding: 8px 16px;
}
.addWuliaoBox {
  padding: 10px 16px;

  .tableBox {
    margin-top: 16px;
    border: 1px solid #e6e6e6;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    overflow: hidden;

    .tt {
      height: 38px;
      line-height: 38px;
      padding-left: 16px;
      background: #f7f8fa;
      border-radius: 8px 8px 0 0;
    }
  }
}
</style>
<style lang="scss">
.selectd {
  td {
    background: #3f61f110;
  }
}
</style>
